package CreateNewItem.WIN;// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   XMLReader.java

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

// Referenced classes of package win:
//            DnkFunctions

public class XMLReader
{

    public XMLReader()
    {
    }

    public static void main(String args[])
    {
        try
        {
            DnkFunctions dnk = new DnkFunctions();
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String dataSourceName = "db1";
            String dbURL = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName).toString();
            Connection con = DriverManager.getConnection(dbURL, "", "");
            Statement st = con.createStatement();
            File file = new File("c:\\NU0807281.xml");
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(file);
            doc.getDocumentElement().normalize();
            NodeList recordList = doc.getElementsByTagName("Record");
            for(int s = 0; s < recordList.getLength(); s++)
            {
                Node recordNodes = recordList.item(s);
                if(recordNodes.getNodeType() != 1)
                    continue;
                Element recordElements = (Element)recordNodes;
                NodeList element1List = recordElements.getElementsByTagName("ITEM_NO");
                Element element1 = (Element)element1List.item(0);
                NodeList list1 = element1.getChildNodes();
                NodeList element2List = recordElements.getElementsByTagName("CATALOG");
                Element element2 = (Element)element2List.item(0);
                NodeList list2 = element2.getChildNodes();
                NodeList element3List = recordElements.getElementsByTagName("DESCRIPT");
                Element element3 = (Element)element3List.item(0);
                NodeList list3 = element3.getChildNodes();
                String DESCRIPT = list3.item(0).getNodeValue();
                DESCRIPT = DESCRIPT.replaceAll("'", " ");
                NodeList element4List = recordElements.getElementsByTagName("R_COST");
                Element element4 = (Element)element4List.item(0);
                NodeList list4 = element4.getChildNodes();
                NodeList element5List = recordElements.getElementsByTagName("RETAIL");
                Element element5 = (Element)element5List.item(0);
                NodeList list5 = element5.getChildNodes();
                NodeList element6List = recordElements.getElementsByTagName("QOH");
                Element element6 = (Element)element6List.item(0);
                NodeList list6 = element6.getChildNodes();
                String QOH = "0";
                if(list6.item(0) != null)
                    QOH = list6.item(0).getNodeValue();
                NodeList element7List = recordElements.getElementsByTagName("LOCATION");
                Element element7 = (Element)element7List.item(0);
                NodeList list7 = element7.getChildNodes();
                String LOCATION = " ";
                if(list7.item(0) != null)
                    LOCATION = list7.item(0).getNodeValue();
                NodeList element8List = recordElements.getElementsByTagName("PART_NO");
                Element element8 = (Element)element8List.item(0);
                NodeList list8 = element8.getChildNodes();
                NodeList element9List = recordElements.getElementsByTagName("BRAND");
                Element element9 = (Element)element9List.item(0);
                NodeList list9 = element9.getChildNodes();
                NodeList element10List = recordElements.getElementsByTagName("MODEL");
                Element element10 = (Element)element10List.item(0);
                NodeList list10 = element10.getChildNodes();
                NodeList element11List = recordElements.getElementsByTagName("NEW_MOD");
                Element element11 = (Element)element11List.item(0);
                NodeList list11 = element11.getChildNodes();
                NodeList element12List = recordElements.getElementsByTagName("YR_L");
                Element element12 = (Element)element12List.item(0);
                NodeList list12 = element12.getChildNodes();
                NodeList element13List = recordElements.getElementsByTagName("YR_H");
                Element element13 = (Element)element13List.item(0);
                NodeList list13 = element13.getChildNodes();
                NodeList element14List = recordElements.getElementsByTagName("COST");
                Element element14 = (Element)element14List.item(0);
                NodeList list14 = element14.getChildNodes();
                NodeList element15List = recordElements.getElementsByTagName("CONTROL");
                Element element15 = (Element)element15List.item(0);
                NodeList list15 = element15.getChildNodes();
                String CONTROL = " ";
                if(list15.item(0) != null)
                    CONTROL = list15.item(0).getNodeValue();
                NodeList element16List = recordElements.getElementsByTagName("REMARK");
                Element element16 = (Element)element16List.item(0);
                NodeList list16 = element16.getChildNodes();
                NodeList element17List = recordElements.getElementsByTagName("LI_WARE");
                Element element17 = (Element)element17List.item(0);
                NodeList list17 = element17.getChildNodes();
                String LI_WARE = "0";
                if(list17.item(0) != null)
                    LI_WARE = list17.item(0).getNodeValue();
                NodeList element18List = recordElements.getElementsByTagName("POSITION");
                Element element18 = (Element)element18List.item(0);
                NodeList list18 = element18.getChildNodes();
                NodeList element19List = recordElements.getElementsByTagName("NEW_DES");
                Element element19 = (Element)element19List.item(0);
                NodeList list19 = element19.getChildNodes();
                try
                {
                    st.execute((new StringBuilder()).append("INSERT INTO tblinventory1 ( categoryid, [part#], description, unitcost, sellingprice, instock, onorder, onhold, onrma, parvalue, location, serialized, discontinued, weight, taxable, vendor1id, vendor2id, vendor3id, lpp, lpf, ldp, lqp, revenueglid, inventoryglid, currentcost, warehouseid, [product#], internet, internetprice, cogid, addinfulfillmentallowed, make, mdl, modeltype, beginyr, endyr, dnkcode, cif, retailprice, sellingprice2, [memo], westwp, fob_t, ecp, ppgprice, slprice, mprice, shapeid, prpkey, instock1, POSITION, NEW_DES ) VALUES(").append(dnk.getCategoryID(list2.item(0).getNodeValue())).append(", '").append(list1.item(0).getNodeValue()).append("', '").append(DESCRIPT).append("', ").append(list4.item(0).getNodeValue()).append(", ").append(list5.item(0).getNodeValue()).append(", ").append(QOH).append(", 0, 0, 0, 0, '").append(LOCATION).append("', no, no, 0, yes, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 3, '").append(list8.item(0).getNodeValue()).append("', yes, ").append(list5.item(0).getNodeValue()).append(", 1, yes, '").append(list9.item(0).getNodeValue()).append("', '").append(list10.item(0).getNodeValue()).append("', '").append(list11.item(0).getNodeValue()).append("', '").append(list12.item(0).getNodeValue()).append("', '").append(list13.item(0).getNodeValue()).append("', '").append(list1.item(0).getNodeValue()).append("', ").append(list14.item(0).getNodeValue()).append(", ").append(list5.item(0).getNodeValue()).append(", ").append(list5.item(0).getNodeValue()).append(", '").append(CONTROL).append(" ").append(list16.item(0).getNodeValue()).append("', 0, 0, 0, 0, 0, 0, 18, 0, ").append(LI_WARE).append(", '").append(list18.item(0).getNodeValue()).append("', '").append(list19.item(0).getNodeValue()).append("')").toString());
                }
                catch(SQLException er) { }
                try
                {
                    st.execute((new StringBuilder()).append("INSERT INTO tblmodel1 ( [part#], make, mdl, modeltype, Description, Beginyr, Endyr, WarehouseID, position, new_des ) VALUES('").append(list1.item(0).getNodeValue()).append("', '").append(list9.item(0).getNodeValue()).append("', '").append(list10.item(0).getNodeValue()).append("', '").append(list11.item(0).getNodeValue()).append("', '").append(DESCRIPT).append("', '").append(list12.item(0).getNodeValue()).append("', '").append(list13.item(0).getNodeValue()).append("', 3, '").append(list18.item(0).getNodeValue()).append("', '").append(list19.item(0).getNodeValue()).append("')").toString());
                }
                catch(SQLException er) { }
            }

            st.close();
            con.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}
